// Figure 3: Municipal Spending and Relative's Vote Margin //

clear all
cap log close

global path ""
use "$path/Main.dta", clear

local vartitle : variable label log_pc_x_totexp 

preserve
lpoly log_pc_x_totexp margin_rel if margin_rel > 0, gen(marpos polpos) ci se(sepos) nograph
lpoly log_pc_x_totexp margin_rel if margin_rel < 0, gen(marneg polneg) ci se(seneg) nograph

foreach v in pos neg {
gen ul`v' = pol`v' + 1.95*se`v'
gen ll`v' = pol`v' - 1.95*se`v'
}

sort marpos
twoway (rarea ulpos llpos marpos, fcolor(gs14) lwidth(none)) (rarea ulneg llneg marneg, fcolor(gs14) lwidth(none)) ///
(scatter log_pc_x_totexp_mv_25 mv_25, msymbol(circle) mlcolor(black) mfcolor(none)) (line polpos marpos, lpattern(solid)  lcolor(black)) (line polneg marneg, lpattern(solid)  lcolor(black)), ///
xline(0, lpattern(dash) lcolor(black)) graphregion(color(white)) legend(off) ytitle("Spending per capita (log)") xtitle("Margin") xscale(titlegap(2)) xlabel(-1(0.1)1) 
restore
